﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using huaguwang.swfupload;

namespace huaguwang.hgmanage.UC
{
    public partial class FLWUpLoad : System.Web.UI.UserControl
    {
        public int M_Index { get; set; }
        public string FilePath { get; set; }
        public void SetIMG(string filePath)
        {
            FilePath = filePath;
            if(FilePath.Length > 0)
            {
                this.txtNewsPic.Text = FilePath;
                this.Image1.ImageUrl = FilePath;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public bool UpLoad()
        {
            if(this.Session["file_info_" + M_Index] != null)
            {
                Thumbnail thumbnails = this.Session["file_info_" + M_Index] as Thumbnail;
                if(thumbnails == null)
                {
                    return false;
                }
                string UploadPath = this.Server.MapPath("/upload/images/");
                string fileName = UploadPath + thumbnails.ID + "." + thumbnails.FileType;
                thumbnails.OldData.SaveAs(fileName);
                this.Session.Remove("file_info_" + M_Index);
                FilePath = "/upload/images/" + thumbnails.ID + "." + thumbnails.FileType;
                return true;
            }
            else
            {
                return false;
            }


        }
    }
}